<?php

declare(strict_types=1);

namespace app\order\controller;

use app\cart\model\GoodsShopcar;
use app\order\model\OrderGoods;
use app\CheckTokenController;
use app\order\model\Order;

class Find extends CheckTokenController
{
    // 根据id查询订单信息
    public function index()
    {

        $params = $this->request->param();
        $DBOrderGoods = new OrderGoods();
        $DBOrder = new Order();
        $DBCart = new GoodsShopcar();
        $orderGoodsInfo = $DBOrderGoods->where('order_id', $params['order_id'])->select()->toArray();
        $orderInfo = $DBOrder->where('order_id', $params['order_id'])->find()->toArray();
        array_push($orderGoodsInfo, $orderInfo);
        if ($orderInfo) {
            return result($orderGoodsInfo);
        }
    }
    // 查询用户下的所有订单
    public function all()
    {
        $params = $this->request->param();
        $DBOrder = new Order();
        $info = $DBOrder->where('uid', $params['uid'])->select();
        return result($info);
    }
}